﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;

namespace Medianamik.Core.Sugar
{
    public static class AsyncHelper
    {
        public static void Execute<T>(Func<T> pAction)
        {
            IAsyncResult result = pAction.BeginInvoke( CallbackMethod<T>, null);
        }

        private static void CallbackMethod<T>(IAsyncResult ar)
        {
            // Retrieve the delegate.
            AsyncResult result = (AsyncResult)ar;
            Func<T> caller = (Func<T>)result.AsyncDelegate;
           
           caller.EndInvoke(ar);
        }
    }
}
